#ifndef MSGPARSERC_H
#define MSGPARSERC_H

#pragma once

#include <QObject>

namespace ns_yht
{
#define MSGPARSERC MsgParserC::instance()
    class MsgParserC : public QObject
    {
        Q_OBJECT
    public:
        MsgParserC();
        ~MsgParserC();

        static MsgParserC *instance();

        void processBuffer(const QByteArray &buffer);

    signals:
        void ownShipReceived(double lat, double lon, double rot, double sog,
                             double cog, double trueheading, double roll,
                             double pitch);
        void windReceived(double windangle, double windspeed);
        void radarRangeChanged(int range);
        void newMsg(const QString msg);
        void timeChanged(qint64 time);

    private:
        void parse(const QByteArray &msg);
        void processOwnShip(const QByteArray &sentence);
        void processTime(const QByteArray &sentence);
        void processAI(const QByteArray &sentence);
        void processRadarRange(const QByteArray &sentence);
        void processMsg(const QByteArray &sentence);

        QByteArray m_lastMsg;
    };

} // namespace ns_yht

#endif